import java.time.Duration;

public class ThreadExample {
    public static void main(String[] args) {
        var thread1 = new Thread(() -> {
            while (true) {
                System.out.println("Thread 1");
                try {
                    Thread.sleep(Duration.ofSeconds(2));
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        var thread2 = new Thread(() -> {
            while (true) {
                System.out.println("Thread 2");
                try {
                    Thread.sleep(Duration.ofSeconds(4));
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        thread1.start();
        thread2.start();
    }
}
